<template>
	<view>
		<myHead :right="true" :text_right="title" @clickRight="clickRight"></myHead>

		<zhiweiguanjianciView v-if="this.loadData.title == 'guanjianci'" :guanjianciData="loadData"
			:guanjianciShow="show3" @toguanjianciData="(e)=>guanjianciIncident(e,'guanjianci')"></zhiweiguanjianciView>

		<zhiweimiaoshuView v-if="this.loadData.title == 'miaoshu'" :miaoshuData="loadData" :miaoshuShow="show3"
			@toguanjianciData="(e)=>guanjianciIncident(e,'miaoshu')"></zhiweimiaoshuView>

		<zhiweimingchengView v-if="this.loadData.title == 'mingcheng'" :name="loadData" :nameShow="show3"
			@toguanjianciData="(e)=>guanjianciIncident(e,'mingcheng')">
		</zhiweimingchengView>

		<zhiweileibieView v-if="this.loadData.title == 'leibie'" :name="loadData"
			@toguanjianciData="(e)=>guanjianciIncident(e,'leibie')"></zhiweileibieView>

		<shangbanshijianView v-if="this.loadData.title == 'OfficeHours'" :guanjianciData="loadData"
			:guanjianciShow="show3" @toguanjianciData="(e)=>guanjianciIncident(e,'OfficeHours')"></shangbanshijianView>

		<gongzuojiaqiView v-if="this.loadData.title == 'Holiday'" :guanjianciData="loadData"
			:guanjianciShow="show3" @toguanjianciData="(e)=>guanjianciIncident(e,'Holiday')"></gongzuojiaqiView>
			
		<gongzuodizhiView v-if="this.loadData.title == 'address'" :name="loadData" :nameShow="show3"
			@toguanjianciData="(e)=>guanjianciIncident(e,'address')"></gongzuodizhiView>

		<u-modal :show="show2" content='确认保存？' showCancelButton @confirm="confirmClick2"
			@cancel="cancelClick2"></u-modal>
	</view>
</template>

<script>
	import myHead from "@/pages/component/baseHead.vue"
	import zhiweiguanjianciView from "@/pages/component/addindex-page/zhiweiguanjianci.vue"
	import zhiweimiaoshuView from "@/pages/component/addindex-page/zhiweimiaoshu.vue"
	import zhiweimingchengView from "@/pages/component/addindex-page/zhiweimingcheng.vue"
	import zhiweileibieView from "@/pages/component/addindex-page/zhiweileibie.vue"
	import shangbanshijianView from "@/pages/component/addindex-page/shangbanshijian.vue"
	import gongzuojiaqiView from "@/pages/component/addindex-page/gongzuojiaqi.vue"
	import gongzuodizhiView from "@/pages/component/addindex-page/gongzuodizhi.vue"
	export default {
		data() {
			return {
				show2: false,
				show3: false,
				loadData: null,
				sanData: null,
				title: '保存'
			}
		},
		components: {
			myHead,
			zhiweiguanjianciView,
			zhiweimiaoshuView,
			zhiweimingchengView,
			zhiweileibieView,
			shangbanshijianView,
			gongzuojiaqiView,
			gongzuodizhiView
		},
		onLoad(e) {
			this.loadData = JSON.parse(e.data)
			if (this.loadData.title == 'leibie') {
				this.title = ''
			}
		},
		
		onShow(e) {
			console.log(e,'onShow-------')
		},

		methods: {
			//职位关键词传过来的数据
			guanjianciIncident(e,val) {
				this.sanData = e;
				this.ToNavigateBack(this.sanData,val)
			},

			//返回上一页  val传的数据
			ToNavigateBack(val,da) {
				// 1. 获取当前页面栈实例（此时最后一个元素为当前页）
				let pages = getCurrentPages()

				// 2. 上一页面实例
				// 注意是length长度，所以要想得到上一页面的实例需要 -2
				// 若要返回上上页面的实例就 -3，以此类推
				let prevPage = pages[pages.length - 2]

				// 3. 给上一页面实例绑定getValue()方法和参数（注意是$vm）
				if(da=='guanjianci'){
					prevPage.$vm.guanjianci(val)
				}else{
					prevPage.$vm.getValue(val)
				}
				uni.navigateBack({
					delta: 1 // 返回的页面数
				})
			},

			// 保存点击事件
			clickRight() {
				this.show2 = true;
			},
			confirmClick2() {
				// let arr = [...this.customList, ...this.wordArr];
				// arr = arr.filter(item => item.checked)
				this.show3 = true;
			},
			cancelClick2() {
				this.show2 = false;
			},
		}
	}
</script>

<style lang="scss" scoped>
	/deep/.u-modal__content__text {
		flex: none;
	}
</style>